package com.qiall.gateway.service;

import java.util.concurrent.ConcurrentHashMap;

/**
 * 单例保存加载后的类
 *
 * @author 吴金辉
 */
public class DubboClassLoaderClassSingleton {

    private ConcurrentHashMap<String, Class<?>> classMap = new ConcurrentHashMap<>();

    /**
     * 私有构造函数
     */
    private DubboClassLoaderClassSingleton() {
    }

    /**
     * 静态内部类
     */
    private static class HolderClass {
        private static final DubboClassLoaderClassSingleton instance = new DubboClassLoaderClassSingleton();
    }

    /**
     * 静态公有工厂方法，返回内部类中创建的实现
     */
    public static ConcurrentHashMap<String, Class<?>> getInstance() {
        return HolderClass.instance.getClassMap();
    }

    public ConcurrentHashMap<String, Class<?>> getClassMap() {
        return classMap;
    }

}
